package org.bambrikii.kbManager.kb2.dao;

import java.util.List;

import org.bambrikii.kbManager.kb2.model.ArtefactAsText;
import org.bambrikii.site.base.core.dao.DAOBase;
import org.bambrikii.site.base.persistence.PersistenceConnector;
import org.hibernate.Query;

public class ArtefactAsTextDAO extends DAOBase<ArtefactAsText> implements IArtefactAsTextDAO {

	public ArtefactAsTextDAO(final PersistenceConnector connector) {
		super(connector);
	}

	public Integer getCountFromQuery(final String query) {
		final Query q = getConnector().getSession().createQuery(query);
		return ((Long) q.uniqueResult()).intValue();
	}

	@SuppressWarnings("unchecked")
	public List<ArtefactAsText> getListFromQuery(final String query, final int start,
			final int length) {
		final Query q = getConnector().getSession().createQuery(query);
		q.setFirstResult(start);
		q.setMaxResults(length);
		return q.list();
	}
}
